﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Fidely.Framework.Integration.WPF">
    <Style TargetType="{x:Type local:AutoCompleteBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:AutoCompleteBox}">
                    <StackPanel>
                        <TextBox Name="PART_TextBox"/>
                        <Popup Name="PART_AutocompletePopup" PlacementTarget="{Binding ElementName=PART_TextBox}" Placement="Bottom" StaysOpen="False" PopupAnimation="Fade" VerticalOffset="2" MaxHeight="200" Width="{Binding PlacementTarget.ActualWidth, RelativeSource={RelativeSource Mode=Self}}">
                            <ListBox Name="PART_AutocompleteListBox" ItemsSource="{Binding}" SelectionMode="Single" SelectedValuePath="CompleteProcedure" HorizontalContentAlignment="Stretch">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <TextBlock Grid.Column="0" Text="{Binding DisplayName}" FontWeight="Bold" Margin="2" Width="100"/>
                                            <TextBlock Grid.Column="1" Text="{Binding Description}" Margin="2"/>
                                            <TextBlock Grid.Column="2" Text="&lt;Shift + Enter&gt;" FontStyle="Italic" Margin="2">
                                                <TextBlock.Style>
                                                    <Style TargetType="TextBlock">
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding IsFirst}" Value="False">
                                                                <Setter Property="Visibility" Value="Collapsed"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </TextBlock.Style>
                                            </TextBlock>
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Popup>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
